package com.molin.networkTest.socketTest.tcpTest.demo2;

import java.io.*;
import java.net.Socket;

public class ClientDemo {

    public static void main(String[] args) throws IOException {
        Socket socket=new Socket("127.0.0.1",8888);

        byte[] bytes="hello".getBytes();
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("hello!".getBytes());
        socket.shutdownOutput();


        BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));

        String s;
        while ((s=br.readLine())!=null){
            System.out.print(s);
        }

        outputStream.close();
        socket.close();
    }
}
